<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <ol class="breadcrumb">
        <li><a href="#">学生成绩管理系统</a></li>
        <li>学生个人主页</li>
    </ol>
    <h3 class="page-header">个人信息</h3>
    <table class="table table-striped">
        <tr>
            <td>学生学号：</td>
            <td v-text="student.sno"></td>
        </tr>
        <tr>
            <td>学生姓名：</td>
            <td v-text="student.sname"></td>
        </tr>
        <tr>
            <td>年级：</td>
            <td v-text="student.gender"></td>
        </tr>
        <tr>
            <td>年龄：</td>
            <td v-text="student.age"></td>
        </tr>
        <tr colspan="2">
            <td><input type="button" value="修改信息" class="btn btn-success btn-sm" @click="updateStudent(student.sno)"></td>
        </tr>
    </table>
    <h3 class="page-header">学生成绩</h3>
    <table class="table table-striped">
        <tr>
            <th>课程号</th>
            <th>课程名称</th>
            <th>成绩</th>
        </tr>
        <tr v-for="(score,index) in datalist">
            <td>{{score.cno}}</td>
            <td>{{score.cname}}</td>
            <td>{{score.score}}</td>
        </tr>
    </table>

    <h3 class="page-header">账号信息</h3>
    <table class="table table-striped">
        <tr>
            <th>昵称</th>
            <th>类别</th>
            <th>邮箱</th>
            <th>操作</th>
        </tr>
        <tr>
            <td v-text="login.loginName"></td>
            <td v-text="Type"></td>
            <td v-text="login.loginEmail"></td>
            <td><input type="button" value="修改密码" class="btn btn-primary btn-sm" @click="updateLogin()"></td>
        </tr>
    </table>


</div>
<script src="js/vue/vue2.5.js"></script>
<script src="js/vue/axios.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/layer/layer.js"></script>
<script>
    new Vue({
        el:'.container',
        data:{
            datalist:[
            ],
            student:{
                sno:'',
                sname:'',
                gender:'',
                age:'',
            },
            login:{
                loginName:'张三花',
                loginEmail:'123',
                loginType:'2',
                loginId:'',
            },
            Type:''
        },
        methods:{
            //查询学生个人信息
            queryStudent(){
                axios.get('/student/query',{params:{sno:101}})
                    .then(resp=>{
                        this.student = resp.data;
                    })
            },
            //修改学生个人信息
            updateStudent(sno) {
                location.href = 'UpdateStudent.html?sno=' + sno;
            },
            //获取学生成绩
            queryScore() {
                axios.get('/score/query2',{params:{sno: 101}})
                    .then(resp =>{
                        this.datalist = resp.data;
                        console.log(this.datalist);
                        console.log(resp.data);
                    })
            },
            //账号信息
            queryLogin(){
                axios.get('/login/query2',{params:{loginId:2}})
                    .then(resp=>{
                        this.login = resp.data;
                        if (resp.data.loginType == 1) {
                            this.Type = '管理员';
                        }else {
                            this.Type = '学生';

                        }
                        console.log(this.login.loginType);
                    })
            },
            //修改密码
            updateLogin() {
                location.href = 'UpdateLogin.html?loginId=' + this.login.loginId + '&loginType=' + this.login.loginType;
            }
        },
        mounted() {
            this.queryStudent();
            this.queryLogin();
            this.queryScore();
        }
    })
</script>
</body>
</html>